<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include  file="/jsps/front/common/taglibs.jsp" %>
<html>
  <head>
  <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
  <link rel="stylesheet" type="text/css" href="<c:url value="/jsps/front/css/page.css"/>">
  <link rel="stylesheet" type="text/css" href="<c:url value="/jsps/front/css/application.css"/>">
	 
	 <script type="text/javascript">
        
        function buy(goodCnt,goodNo,index){
           //alert(${good.goodsName});
           var goodNum=document.getElementById('goodNum'+index).value;
           if(goodNum>goodCnt)
             alert("你所要购买的商品数量大于库存量，请重新输入!");
          else if(confirm("你确认要购买"+goodNum+"件"+"该商品吗?")){
              window.open('<c:url value="/goodMgr?act=addGoodToCart"/>&goodNo='+goodNo+'&goodNum='+goodNum);
             }  
        }
        
         function doQuery(pageno)
         {
           if(pageno<1 || pageno>${pagedGood.totalPageNum})
           {
              alert("页号超出范围，有效范围：[1-${pagedGood.totalPageNum}]!");
              ${'pageNo'}.select();
              return;
           }
           location.href='<c:url value="/goodMgr?act=loadAll"/>&pageNo='+pageno;  
         }
    </script>   

  </head>
  
  <body>
  <c:if test="${not empty pagedGood}">
	 <table  cellpadding="0" align="center" cellspacing="0" border="1" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#819BBC">
            <tr>
               <DIV class="top">
						<A title=商品上架 target="_blank"
							href="<c:url value="/#"/>" name=more>
							 <IMG src="<c:url value='/jsps/front/images/xinpinshangjia.jpg'/>" border=0> </A>
				</DIV>
            </tr>
            
            <c:forEach items="${pagedGood.pageContent}" var="good" varStatus="idxStatus">
       		<tr>
             <td class=good_left style="width:100px;">
					<div class=g_pic >
					    <A title=商品图片 target="_blank"
							href="<c:url value="/goodMgr?act=showGood&goodNo=${good.goodsNo}"/>" name=purchase_bk>
							 <img id=img style="width: 150px; height: 150px; align:center;" title="商品图片" 
							 src="<c:url value="/goodMgr?act=showGoodCover"/>&goodNo=${good.goodsNo}" border=0/> 
						</A>
					</DIV>
			 </td>
			 <td>
				<DIV class=good_right style="font-size:20px" style="width: 150px; height: 150px; align:center;">
					<DIV>商品名称：${good.goodsName}</DIV>
					<div style="margin-top: 2px;">
					<DIV class=price>
						<SPAN class=gray87>单价: ${good.goodsPrice}元</SPAN>
					</DIV>
					<div class=buy>
			          <span>商品数量:</span>	
			           <select name="goodNum${idxStatus.index}">
			            <c:forEach var='x' begin='1' end='${good.cnt }' step='1'>
			             <option value=${ x}>${ x}</option>
			            </c:forEach>
			          </select>
	        		</div>	     
					<span class=buy>
					 <a target="_blank"> 
					   <IMG onclick="buy(${good.cnt },${good.goodsNo },${idxStatus.index});" 
					         src="<c:url value="/jsps/front/images/jrgw.jpg" />">
					  </a>
					</span>
				
					<span class=detail style="float:right;font-size=15px;font-color:red;">
						<A href="<c:url value="/goodMgr?act=showGood&goodNo=${good.goodsNo}"/>" target=_blank>详细信息</A>
					</span>
				   </div>
				</DIV>
				</td>
                
              </tr>
              </c:forEach>
             
            </table>
    
            <div id="pageinfo">
	            共${pagedGood.totalRecNum}条, 当前显示${pagedGood.startIndex}-${pagedGood.endIndex}条, 第${pagedGood.pageNo}/${pagedGood.totalPageNum}页
	           |
	           <c:if test="${pagedGood.pageNo>1}">
	             <span class="linkspan" onclick="doQuery(1)">首页</span>&nbsp;
	           </c:if>
	           <c:if test="${pagedGood.prePage}">
	             <IMG onclick="doQuery(${pagedGood.pageNo-1});" title="上一页" src="<c:url value="/jsps/front/images/page_up_mouseover.gif" />">&nbsp;
	           </c:if>
	           <c:if test="${pagedGood.nextPage}">
	              <IMG onclick="doQuery(${pagedGood.pageNo+1});" title="下一页" src="<c:url value="/jsps/front/images/page_down.gif" />">&nbsp;
	           </c:if>
	           <c:if test="${pagedGood.pageNo!=pagedGood.totalPageNum}">
	             <span class="linkspan" onclick="doQuery(${pagedGood.totalPageNum})">末页</span>&nbsp;
	           </c:if>
	           |
	            到<input type="text" id="pageNo" size=4 style="text-align:right;" onkeypress="onlynumber();"/> 页
	           <button onclick="doQuery(document.getElementById('pageNo').value);"> 跳 转 </button>		           		           	           	              
	   </div>
          </c:if>  
  </body>
</html>
